package com.sz.app.edi.job.order;

import com.sz.app.edi.service.order.CusOrderTrackingService;
import com.sz.common.base.job.JobScheduler;
import com.sz.common.base.logger.Logger;
import com.sz.biz.logistics.ord.entity.OrdTrackingMessage;
import com.sz.biz.logistics.ord.service.OrdTrackingMessageService;
import com.sz.biz.logistics.ord.enums.TrackMessageToServiceEnum;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Function: 向供应商发揽货信息 <br>
 * Author: hpeng.wang. <br>
 * Date: 2017-05-23 14:26:00.
 */
//@Service("orderStatusJobScheduler")
public class OrderTrackingJobSchedulerImpl implements JobScheduler {
    Logger logger = Logger.getLogger(this.getClass());
    @Autowired
    private OrdTrackingMessageService ordTrackingMessageService;
    @Autowired
    private CusOrderTrackingService cusOrderTrackingService;

    @Override
    public void execute() {
        logger.info("==============start OrderTrackingJobScheduler");
        long start = System.currentTimeMillis();

        //下发取货订单
        List<OrdTrackingMessage> orderTrackingList = ordTrackingMessageService.findReceTracking(TrackMessageToServiceEnum.PLACE_TRADE_ORDER);
        cusOrderTrackingService.syncReceGoodInfo(orderTrackingList, TrackMessageToServiceEnum.PLACE_TRADE_ORDER);
        //更新取货订单
        orderTrackingList = ordTrackingMessageService.findReceTracking(TrackMessageToServiceEnum.UPDATE_TRADE_ORDER);
        cusOrderTrackingService.syncReceGoodInfo(orderTrackingList, TrackMessageToServiceEnum.UPDATE_TRADE_ORDER);

        long end = System.currentTimeMillis();
        logger.info("==============end OrderTrackingJobScheduler,use time:" + (end - start) + "ms");
    }
}
